package lol.niconico.libtest.di

import android.util.Log
import androidx.fragment.app.FragmentActivity
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.EntryPoint
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.components.FragmentComponent
import lol.niconico.libtest.TestData
import javax.inject.Inject
import javax.inject.Qualifier
import javax.inject.Singleton

/**
 * Created by ZhangQianqian on 2020/7/7  14:59.
 * email 415692689@qq.com
 */
@Singleton
class L @Inject constructor() {
    private val time: String = System.currentTimeMillis().toString()
    fun analyticsMethods(): String {
        return " ====  time:$time"
    }
}

@Module
@InstallIn(ActivityComponent::class)
abstract class ServiceModule {

    @Binds
    abstract fun provideAnalyticsService(service: AnalyticsServiceImpl): AnalyticsService
}


class AnalyticsAdapter @Inject constructor(
    val service: AnalyticsService
)


interface AnalyticsService {
    fun analyticsMethods(): String
}


class AnalyticsServiceImpl @Inject constructor(
    private val activity: FragmentActivity
) : AnalyticsService {
    private val time: String = System.currentTimeMillis().toString()

    override fun analyticsMethods(): String {
        Log.e("AnalyticsServiceImpl", time)
        return "AnalyticsServiceImpl====  time:$time"
    }
}

@EntryPoint
@InstallIn(ActivityComponent::class)
interface ExampleContentProviderEntryPoint {
    fun analyticsService(): AnalyticsService
}
